@extends('layouts.app')

@section('content')
    <div class="container">
        <div class="row">
            <div class="panel panel-default">
                <div class="panel-heading">菜单
                    <a href="{{ url("menu/edit") }}" class="btn btn-primary btn-sm active" role="button">添加菜单</a>
                    <a href="{{ url("menu/sync") }}" class="btn btn-primary btn-sm active" role="button">同步菜单到公众号</a>
                    <a href="{{ url("menu/getfromremote") }}" class="btn btn-primary btn-sm active" role="button">从公众号同步到本地</a>
                </div>
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>菜单名称</th>
                            <th>排序</th>
                            <th>类型</th>
                            <th class="col-xs-7">值</th>
                            <th>管理</th>
                        </tr>
                    </thead>
                    <tbody>
                    @foreach($menus as $item)
                        <tr>
                            <td>{{ $item->id }}</td>
                            <td>{{ $item->name }}</td>
                            <td>
                                <a href="{{ url("menu/order/".$item->id."/left") }}" class="glyphicon glyphicon-arrow-up"></a>
                                <a href="{{ url("menu/order/".$item->id."/right") }}" class="glyphicon glyphicon-arrow-down"></a>
                            </td>
                            <td>{{ $item->typename }}</td>
                            <td>{{ $item->value }}</td>
                            <td>
                                <a href="{{ url("menu/edit",[$item->id]) }}">修改</a> | <a href="{{ url("menu/delete/".$item->id) }}">删除</a>
                            </td>
                        </tr>
                        @foreach($item->children()->get() as $child)
                            <tr>
                                <td>{{ $child->id }}</td>
                                <td><span class="glyphicon glyphicon-minus" aria-hidden="true"></span>{{ $child->name }}</td>
                                <td>
                                    <a href="{{ url("menu/order/".$child->id."/left") }}" class="glyphicon glyphicon-arrow-up"></a>
                                    <a href="{{ url("menu/order/".$child->id."/right") }}" class="glyphicon glyphicon-arrow-down"></a>
                                </td>
                                <td>{{ $child->typename }}</td>
                                <td>{{ $child->value }}</td>
                                <td>
                                    <a href="{{ url("menu/edit",[$child->id]) }}">修改</a> | <a href="{{ url("menu/delete/".$child->id) }}">删除</a>
                                </td>
                            </tr>
                        @endforeach
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>

@endsection
